////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Filename:    RainDanceGuts.h                                               //
//  Developer:   Tommy Riddle                                                 //
//  Create date: 10/19/2005                                                   //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Description: This is the class declaration for the slot gut of the        //
//               Australian Slot machine called Rain Dance.                   //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//        Copyright (c) 2005 - Realtime Gaming.  All rights reserved.         //
////////////////////////////////////////////////////////////////////////////////

#if !defined(__RAINDANCEGUTS_H__)
#define __RAINDANCEGUTS_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "slotguts.h"
#include "getrand.h"

class RainDanceGuts : public SlotGuts
{
public:
	RainDanceGuts();

	virtual ~RainDanceGuts();

private:
	// Shared enums between client and server
	#include "RainDanceCommon.h"

	// Helpful lookup arrays.
	static SpinResult m_aLineWinSpinResults[NUM_VALID_ICONS][6];

	static SpinResult m_aScatterWinSpinResults[6];

	// Inline functions to use with the arrays that also do
	// bounds checking.
	static SpinResult lookupLineWinSpinResult( uint8 nIconType, uint8 nCount )
	{
		if ( nIconType < NUM_VALID_ICONS && nCount < 6 )
		{
			return m_aLineWinSpinResults[ nIconType ][ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

	static SpinResult lookupScatterWinSpinResult( uint8 nCount )
	{
		if ( nCount < 6 )
		{
			return m_aScatterWinSpinResults[ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

	static uint8 getFreeSpinMultiplierNoteId( uint8 nMultiplier )
	{
		if ( nMultiplier == 3 )
		{
			return NOTE_3X_FREE_SPIN;
		}
		else if ( nMultiplier == 4 )
		{
			return NOTE_4X_FREE_SPIN;
		}
		else if ( nMultiplier == 5 )
		{
			return NOTE_5X_FREE_SPIN;
		}

		ASSERT( false );
		return 0;
	}

	uint8 getCurrentMultiplier()
	{
		uint8 nRV = m_subGame->getData( SGDIDX_CURRENT_MULTIPLIER );

		ASSERT( nRV == 1 || nRV == 3 || nRV == 4 || nRV == 5 );

		return nRV;
	}

	void setCurrentMultiplier( uint8 nMultiplier )
	{
		ASSERT( nMultiplier == 1 || nMultiplier == 3 || nMultiplier == 4 || nMultiplier == 5 );
		m_subGame->update( SGDIDX_CURRENT_MULTIPLIER, nMultiplier );
	}

	static int32 getNumFreeGamesToAward( uint8 nScatterCount )
	{
		if ( nScatterCount == 3 )
		{
			return 10;
		}
		else if ( nScatterCount == 4 )
		{
			return 15;
		}
		else if ( nScatterCount == 5 )
		{
			return 100;
		}

		ASSERT( false );
		return 0;
	}

	// Helper functions for classifyStops.
	SpinResult getChiefLineWinResult( uint8* stops ) const;

	SpinResult getLineWinResultWithPossibleSubstitution( uint8* stops, uint8 testIcon, bool& bSubstitution ) const;

	bool doesChiefLineWinPayMore( SpinResult srChief, SpinResult srOther, bool bSubstitution ) const;

	void tryForJackpot( SlotSpin* spin );
	
	SpinResult getScatterWinResult( SlotSpin* spin, int32& scatterPositions, bool& bSubstitution, uint8& numScatterIcons ) const;

	void evaluateScatterWin( SlotSpin* spin, SpinResult srScatterResult, int32 scatterPositions, bool bSubstitution );

	void evaluateFeatureTrigger( SlotSpin* spin, SpinResult srScatterResult, int32 scatterPositions, uint8 numScatterIcons );

	void resetReelHoldStops();
	int32 getReelHoldStop( uint8 nReel );
	void setReelHoldStop( uint8 nReel, int32 nStop );

public:
	virtual void classifyStops( SpinLine* spinline, uint8* stops, uint8 bet, uint8 line,
		uint8& rtnresult, uint8& multiplier );

	virtual void classifyScatters( SlotSpin *spin );

    virtual bool8 isValidGuts();

    virtual void getGameModeMultiplierAndNoteId( uint8& nGameModeMultiplier, uint8& nNoteId );

protected:
	// Override of the framework function.
	virtual void preSpinClassifyResults( SlotSpin *spin );
	virtual void Debug_SetLoserStops( uint8* pStops );
};

#endif // !defined(__RAINDANCEGUTS_H__)
